home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / ixemlsrc.lha / ixemul / library / __unlock.c < prev    next >
C/C++ Source or Header  |  1995-12-23  |  3KB  |  88 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  __unlock.c,v 1.1.1.1 1994/04/04 04:30:13 amiga Exp
  20.  *
  21.  *  __unlock.c,v
  22.  * Revision 1.1.1.1  1994/04/04  04:30:13  amiga
  23.  * Initial CVS check in.
  24.  *
  25.  *  Revision 1.3  1992/08/09  20:40:01  amiga
  26.  *  change to use 2.x header files by default
  27.  *
  28.  *  Revision 1.2  1992/07/28  02:50:59  mwild
  29.  *  call FreeDosObject instead of kfree() when > 1.3
  30.  *
  31.  *  Revision 1.1  1992/05/14  19:55:40  mwild
  32.  *  Initial revision
  33.  *
  34.  */
  35.  
  36. #define KERNEL
  37. #include "ixemul.h"
  38.  
  39. int __unlock (BPTR lock)
  40. {
  41.   struct StandardPacket *sp;
  42.   
  43.   sp = alloca(sizeof(*sp)+2);
  44.   sp = LONG_ALIGN (sp);
  45.   __init_std_packet(sp);
  46.  
  47.   sp->sp_Pkt.dp_Port = u.u_sync_mp;
  48.   sp->sp_Pkt.dp_Type = ACTION_FREE_LOCK;
  49.   sp->sp_Pkt.dp_Arg1 = lock;
  50.  
  51.   PutPacket (((struct FileLock *)BTOCPTR (lock))->fl_Task, sp);
  52.   __wait_sync_packet (sp);
  53.   
  54.   /* set up Result2 so that the IoErr() works */
  55.   ((struct Process *)FindTask (0))->pr_Result2 = sp->sp_Pkt.dp_Res2;
  56.  
  57.   return sp->sp_Pkt.dp_Res1;
  58. }
  59.  
  60. /* ATTENTION: name-clash between sysio-__close and DOS-__Close !! */
  61. void __Close (BPTR fh)
  62. {
  63.   struct StandardPacket *sp;
  64.   struct FileHandle *fhp = BTOCPTR (fh);
  65.   
  66.   /* only do this is not closing a dummy NIL: filehandle */
  67.   if (fhp->fh_Type)
  68.     {
  69.       sp = alloca(sizeof(*sp)+2);
  70.       sp = LONG_ALIGN (sp);
  71.       __init_std_packet(sp);
  72.  
  73.       sp->sp_Pkt.dp_Port = u.u_sync_mp;
  74.       sp->sp_Pkt.dp_Type = ACTION_END;
  75.       sp->sp_Pkt.dp_Arg1 = fhp->fh_Arg1;
  76.  
  77.       PutPacket (fhp->fh_Type, sp);
  78.       __wait_sync_packet (sp);
  79.  
  80.       /* set up Result2 so that the IoErr() works */
  81.       ((struct Process *)FindTask (0))->pr_Result2 = sp->sp_Pkt.dp_Res2;
  82.     }
  83.   else
  84.     ((struct Process *)FindTask (0))->pr_Result2 = 0;
  85.   
  86.   FreeDosObject (DOS_FILEHANDLE, fhp);
  87. }
  88.